/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.p10.miage.gestionabsence.model;

import java.sql.DriverManager;
import java.sql.SQLException;

/**
 *
 * @author Sofian Seid
 */
public class Connection {

    private static java.sql.Connection cx;
    
    public Connection() { 
        try {
            Class.forName("oracle.jdbc.driver.OracleDriver");
        }
        catch( ClassNotFoundException ex ) {
            System.err.println( "Erreur lors du chargement du driver" );
            System.exit(1);
        }
        try {

         /*String url="jdbc:oracle:thin:@miage03.dmiage.u-paris10.fr:1521:MIAGE";
         String user="delati";
         String pwd="apprentis2012pw";*/   
            
         String url = "jdbc:oracle:thin:@localhost:1521:xe";
         String user="delati";
         String pwd = "hockey";           
            
         Connection.cx =DriverManager.getConnection (url, user, pwd);
        }
        catch( SQLException ex ) {
            System.err.println( "Erreur lors de la cx à la base: "+ex );
            System.exit(1);
        }
    }
    
    public static java.sql.Connection getBDD(){
        
        if(Connection.cx==null){
            Connection connection = new Connection();
        }
        return Connection.cx;
    }
    
    
}
